home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / bibtex99.zip / BIBTEX.CHP next >
Text File  |  1988-12-18  |  16KB  |  554 lines

  1.  
  2. *       change banner
  3.  
  4. @x
  5. @d banner=='This is BibTeX, Version 0.99c' {printed when the program starts}
  6. @y
  7. @d banner=='This is BibTeX, Version 0.99c (MS-DOS port by D. Vulis/J. Demel)'
  8. @z
  9.  
  10. *       include input and output
  11.  
  12. @x
  13. @d term_out == tty
  14. @d term_in == tty
  15. @y
  16. @d term_out == output
  17. @d term_in == input
  18. @z
  19.  
  20. *       case statement changed for Prof. Pascal
  21.  
  22. @x
  23. @d othercases == others:        {default for cases not listed explicitly}
  24. @y
  25. @d othercases == otherwise {default for cases not listed explicitly}
  26. @z
  27.  
  28. *       If you compiler does not support this, get rid of it.
  29.  
  30. @x
  31. @d incr(#) == #:=#+1    {increase a variable by unity}
  32. @d decr(#) == #:=#-1    {decrease a variable by unity}
  33. @y
  34. @d incr(#) == inc(#)
  35. @d decr(#) == dec(#)
  36. @z
  37.  
  38. *       The following stuff is highly ...-dependent; also, I had to re-insert
  39. *       the underlines by hand.
  40.  
  41. @x
  42. @<Compiler directives@>=
  43. @{@&$C-,A+,D-@}  {no range check, catch arithmetic overflow, no debug overhead}
  44. @!debug @{@&$C+,D+@}@+ gubed            {but turn everything on when debugging}
  45. @y
  46. @<Compiler directives@>=
  47. @=pragma off(floating_point);@>
  48. @=pragma data_aliasing_convention ('%a%r');@>
  49. @=pragma routine_aliasing_convention ('%a%r');@>
  50. @=pragma off(check_nil);@>
  51. @=pragma on(push_regsize);@>
  52. @=pragma off(check_range);@>
  53. @=pragma off(check_stack);@>
  54. @=pragma off(check_string);@>
  55. @=pragma off(check_subscript);@>
  56. @=pragma off(emit_line_records);@>
  57. @=pragma off(emit_line_table);@>
  58. @=pragma off(emit_names);@>
  59. @=pragma on(optimize_unsigned_words);@>
  60. @=pragma on(optimize_withs);@>
  61. @=pragma memory_model(large);@>
  62. @=pragma c_include('implement.pf');@>@\
  63. package arg;
  64. @=        pragma routine_aliasing_convention(Implement.RTE_aliasing);@>
  65.         type args_type = string(256);
  66.         function args:args_type;  external;
  67. end;
  68. with arg;
  69. @=pragma alias(arg,Implement.RTE || 'arg'); @>
  70. package status;
  71. @=pragma routine_aliasing_convention(Implement.RTE_aliasing); @>
  72. var @=Return_IO_status@>:boolean;
  73.         errno: cardinal;
  74. procedure perror(const S: string); external;
  75. end{package};
  76. @=pragma alias(status,Implement.RTE || 'status'); @>
  77. with status;
  78. @=pragma c_include('env.pf');@>@\{get routines to access environment-variable}
  79. with env;
  80. @z
  81.  
  82. *       We have to cut this down to reduce memory requirements.
  83. *       3000 requires 580 kbyte free memory
  84. *       2500 requires 530 kbyte free memory
  85.  
  86. @x
  87. @!max_ent_strs=3000; {maximum number of |str_entry_var|s
  88. @y
  89. @!max_ent_strs=2500; {maximum number of |str_entry_var|s
  90. @z
  91.  
  92.  
  93. *                               J.Demel  1988-12-10
  94. *       position tangle to correct paragraph
  95.  
  96. @x
  97. @* Input and output.
  98. @y
  99. @* Input and output.
  100. @z
  101.  
  102.  
  103. *       definition of text-files changes
  104.  
  105. @x
  106. @<Types in the outer block@>=
  107. @!alpha_file=packed file of text_char;  {files that contain textual data}
  108. @y
  109. @<Types in the outer block@>=
  110. @!alpha_file=text; {files that contain textual data}
  111. @z
  112.  
  113.  
  114. *       open/close of internal files
  115.  
  116. @x
  117. @d reset_OK(#)==erstat(#)=0
  118. @d rewrite_OK(#)==erstat(#)=0
  119.  
  120. @<Procedures and functions for file-system interacting@>=
  121. function erstat(var f:file):integer; extern;    {in the runtime library}
  122. @#@t\2@>
  123. function a_open_in(var f:alpha_file):boolean;   {open a text file for input}
  124. begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
  125. end;
  126. @#
  127. function a_open_out(var f:alpha_file):boolean;  {open a text file for output}
  128. begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
  129. end;
  130.  
  131.  
  132. @
  133. @y
  134.  
  135. @<Procedures and functions for file-system interacting@>=
  136. @#
  137. function a_open_in(var f:alpha_file):boolean; {open a text file for input}
  138. begin reset(f,name_of_file);
  139. a_open_in:=(errno=0);
  140. if not a_open_in then perror('a_open_in ' || name_of_file);
  141. end;
  142. @#
  143. function a_open_out(var f:alpha_file):boolean; {open a text file for output}
  144. begin rewrite(f,name_of_file);
  145. a_open_out:=(errno=0); 
  146. if not a_open_out then perror('a_open_out ' || name_of_file);
  147. end;
  148.  
  149.  
  150. @
  151.  
  152. We have to enable IO-Status-codes
  153.  
  154. @<Set initial values of key variables@>=
  155. @=Return_IO_status@> := true;
  156.  
  157. @
  158. @z
  159.  
  160.  
  161. *
  162.  
  163. @x
  164. @!buf_type = array[buf_pointer] of ASCII_code;  {for various buffers}
  165. @y
  166. @!buf_type = packed array[buf_pointer] of ASCII_code; {for various buffers}
  167. @z
  168.  
  169.  
  170. *       put string-pool in a seperate segment
  171.  
  172. @x
  173. @!str_pool : packed array[pool_pointer] of ASCII_code;  {the characters}
  174. @y
  175. @=pragma data(common,'pool'); @>
  176. var
  177. @!str_pool : packed array[pool_pointer] of ASCII_code;  {the characters}
  178. @=pragma data; @>
  179. var
  180. @z
  181.  
  182. *       near line 1678
  183. *       put some large arrays into a seperate segment
  184.  
  185. @x
  186. @!hash_next : packed array[hash_loc] of hash_pointer;   {coalesced-list link}
  187. @!hash_text : packed array[hash_loc] of str_number;     {pointer to a string}
  188. @!hash_ilk : packed array[hash_loc] of str_ilk;         {the type of string}
  189. @!ilk_info : packed array[hash_loc] of integer;         {|ilk|-specific info}
  190. @y
  191. @=pragma data(common,'hash'); @>
  192. var
  193. @!hash_next : packed array[hash_loc] of hash_pointer;   {coalesced-list link}
  194. @!hash_text : packed array[hash_loc] of str_number;     {pointer to a string}
  195. @!hash_ilk : packed array[hash_loc] of str_ilk;         {the type of string}
  196. @!ilk_info : packed array[hash_loc] of integer;         {|ilk|-specific info}
  197. @=pragma data; @>
  198. var
  199. @z
  200.  
  201.  
  202. *    Lines 1862-1908         J.Demel   1988-12-11
  203. *    initialize the bst_ and bib_area from MS-DOS Environment variables
  204.  
  205. @x
  206. @!s_bib_area : str_number;      {\.{texbib:}}
  207. @y
  208. @!s_bib_area : str_number;      {\.{texbib:}}
  209. env_value : string(file_name_size);     {temp storage for environment variable}
  210. @z
  211.  
  212. @x
  213. pre_define('texinputs:  ',10,file_area_ilk);
  214. s_bst_area := hash_text[pre_def_loc];
  215. pre_define('texbib:     ',7,file_area_ilk);
  216. s_bib_area := hash_text[pre_def_loc];
  217. @y
  218. env_value := @=Get_env@>('TEXINPUT');
  219. if (@=length@>(env_value)=0) then
  220.      env_value := @=Get_env@>('TEXINPUTS');  {check alternate name}
  221. if (@=length@>(env_value)<>0) then
  222.      if env_value[@=length@>(env_value)]<>'\' then
  223.         env_value := env_value || '\';       {append \ }   
  224. pre_define(env_value,@=length@>(env_value),file_area_ilk);
  225. s_bst_area := hash_text[pre_def_loc];
  226.  
  227. env_value := @=Get_env@>('TEXBIB');
  228. if env_value[@=length@>(env_value)]<>'\' then
  229.         env_value := env_value || '\';
  230. pre_define(env_value,@=length@>(env_value),file_area_ilk);
  231. s_bib_area := hash_text[pre_def_loc];
  232. @z
  233.  
  234. *       must change parameter-definition to get the full path-name
  235.  
  236. @x
  237. procedure pre_define (@!pds:pds_type; @!len:pds_len; @!ilk:str_ilk);
  238. @y
  239. procedure pre_define (@!pds:string(file_name_size);
  240.                       @!len:pds_len; @!ilk:str_ilk);
  241. @z
  242.  
  243.  
  244. *       Near line 2452
  245. *       Process command-line
  246.         
  247. @x
  248. @<Procedures and functions for the reading and processing of input files@>=
  249. procedure get_the_top_level_aux_file_name;
  250. label aux_found,@!aux_not_found;
  251. var @<Variables for possible command-line processing@>@/
  252. begin
  253. check_cmnd_line := false;                       {many systems will change this}
  254. loop
  255.     begin
  256.     if (check_cmnd_line) then
  257.         @<Process a possible command line@>
  258.       else
  259.         begin
  260.         write (term_out,'Please type input file name (no extension)--');
  261.         if (eoln(term_in)) then                 {so the first |read| works}
  262.             read_ln (term_in);
  263.         aux_name_length := 0;
  264.         while (not eoln(term_in)) do
  265.             begin
  266.             if (aux_name_length = file_name_size) then
  267.                 begin
  268.                 while (not eoln(term_in)) do    {discard the rest of the line}
  269.                     get(term_in);
  270.                 sam_you_made_the_file_name_too_long;
  271.                 end;
  272.             incr(aux_name_length);
  273.             name_of_file[aux_name_length] := term_in^;
  274.             get(term_in);
  275.             end;
  276.         end;
  277. @y
  278. @<Procedures and functions for the reading and processing of input files@>=
  279. procedure get_the_top_level_aux_file_name;
  280. label aux_found,@!aux_not_found;
  281. var @<Variables for possible command-line processing@>@/
  282. begin
  283. s:=args;
  284. t:=@=length@>(s);
  285. k:=1;
  286. while